﻿using System.Collections.Generic;
using ELab.Communication;
using ELab.Communication.Messages;

namespace ELab.Organization
{
    /// <summary>
    /// Represents a Client Application that can send and received messages to/from this server.
    /// </summary>
    public class ELabClientApplication : ELabPersistentRemoteApplicationBase
    {
        #region Public properties

        /// <summary>
        /// Communicator type for Client applications.
        /// </summary>
        public override CommunicatorTypes CommunicatorType
        {
            get { return CommunicatorTypes.Application; }
        }

        #endregion

        #region Constructors

        /// <summary>
        /// Creates a new ELabClientApplication.
        /// </summary>
        /// <param name="name">Unique name of the application</param>
        public ELabClientApplication(string name)
            : base(name)
        {
            //No action
        }

        #endregion

        #region Protected / Overrive methods



        /// <summary>
        /// Gets Id of last incoming message that will be sent to this application.
        /// </summary>
        /// <returns>Id of last incoming message</returns>
        protected override int GetMaxWaitingMessageId()
        {
            throw new System.NotImplementedException();
        }

        /// <summary>
        /// Finds Next server for a message.
        /// </summary>
        /// <returns>Next server</returns>
        protected override string GetNextServerForMessage(ELabDataTransferMessage message)
        {
            //Next server and destination server is same (this server) because message is being delivered to application now.
            return message.DestinationServerName;
        }

        #endregion
    }
}
